package com.hmall.item.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

@Configuration
public class MyInterceptorConfig extends WebMvcConfigurationSupport /*implements WebMvcConfigurer*/ {


    @Override
        protected void addInterceptors(InterceptorRegistry registry) {
            // 将上面自定义好的拦截器添加进去。
            registry.addInterceptor(new MyHandlerInterceptor()).addPathPatterns("/**");
            super.addInterceptors(registry);
        }
    /*
            @Override
            protected void addResourceHandlers(ResourceHandlerRegistry registry) {
                registry.addResourceHandler("/**").addResourceLocations("classpath:/**");
                super.addResourceHandlers(registry);
            }*/
    /*@Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 实现WebMvcConfigurer不会导致静态资源被拦截
        registry.addInterceptor(new MyHandlerInterceptor()).addPathPatterns("/**");
    }*/


}
